import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-08-16
 * Time: 9:03
 */
public class August16th {

}

class Animal{
    public String name;
    private int age;
    public Animal(String name,int age){
        this.name=name;
        this.age=age;
    }
    public void eat(){
        System.out.println(this.name+"吃饭");
    }
    public void eat1(){
        System.out.println(this.name+"吃饭1");
    }
}
class Dog extends Animal{
    public Dog(String name,int age) {
        super(name,age);
    }
    public void eat() {
        System.out.println(this.name+"吃骨头");
    }
    public void bark() {
        System.out.println(this.name+"www");
    }
}
class Cat extends Animal{
    public Cat(String name,int age) {
        super(name,age);
    }
    public void eat() {
        System.out.println(this.name+"吃小鱼");
    }
    public void mew() {
        System.out.println(this.name+"mmm");
    }
}
class TestAnimal{
    public static void testc(Animal animal){
        animal.eat();
    }
    public static void main(String[] args) {
        Animal animal=new Dog("qwert",111);
        if(animal instanceof Cat){
            Cat cat=(Cat)animal;
            cat.mew();
        }
        if(animal instanceof Dog){
            Dog dog=(Dog) animal;
            dog.bark();
        }
    }
}




class Shape{
    public void draw(){
        System.out.println("画图形");
    }
}
class Rect extends Shape{
    @Override
    public void draw() {
        System.out.println("菱形");
    }
}
class Cycle extends Shape{
    @Override
    public void draw() {
        System.out.println("圆形");
    }
}
class C extends Shape{
    @Override
    public void draw() {
        System.out.println("c");
    }
}
class Test2{
    public static void drawShapes1(){
        Rect rect=new Rect();
        Cycle cycle=new Cycle();
        String[] shapes={"cycle","rect","cycle","rect"};

        for (String shape: shapes) {
            if(shape.equals("cycle")){
                cycle.draw();
            }else{
                rect.draw();
            }
        }
    }
    public static void drawShapes2(){
        Rect rect=new Rect();
        Cycle cycle=new Cycle();
        Shape[] shapes={new Cycle(),new Rect(),new Cycle(),new Rect()};

        for (Shape shape: shapes) {
            shape.draw();
        }
    }
    public static void main(String[] args) {
        drawShapes2();
    }
}







class B{
    public B(){
        func();
    }
    public void func(){
        System.out.println("B.func()");
    }
}
class D extends B{
    private int num=1;
    @Override
    public void func() {
        System.out.println("D.func()"+num);
    }
}
class E extends D{
    private int num=1;
    @Override
    public void func() {
        System.out.println("D.func()"+num);
    }
}
class Test3{
    public static void main(String[] args) {
        B d=new B();
        B d1=new D();
        B d2=new E();
    }
}
















